<?php echo $this->render('./includes/header.phtml');?>
<?php echo $this->render('./includes/fix_top_menu.phtml');?>
	<div id="container" class="row-fluid">
		<?php echo $this->render('./includes/menu.phtml');?>
		<script language="javascript" type="text/javascript">
		function jsFunction(id){
			  var myselect = document.getElementById(id);
			  if(myselect.options[myselect.selectedIndex].value == "") {
				  document.getElementById('tour'+id).style.display = 'none';
				  document.getElementById('loc'+id).style.display = 'none';
			  } else if(myselect.options[myselect.selectedIndex].value == 1) {
				  document.getElementById('tour'+id).style.display = 'block';
				  document.getElementById('loc'+id).style.display = 'none';
			  } else if(myselect.options[myselect.selectedIndex].value == 2) {
				  document.getElementById('tour'+id).style.display = 'none';
				  document.getElementById('loc'+id).style.display = 'block';
			  }
			}
		function tourFunction(id, photoid){
			  var myselect = document.getElementById(id);
			  if(myselect.options[myselect.selectedIndex].value != "") {
				  window.location.href="<?php echo $this->baseUrl('/photo/?ctour=1&tour_id=');?>" + myselect.options[myselect.selectedIndex].value + "&photo_id=" + photoid;
			  }
			}
		function locFunction(id, photoid){
			  var myselect = document.getElementById(id);
			  if(myselect.options[myselect.selectedIndex].value != "") {
				  window.location.href="<?php echo $this->baseUrl('/photo/?cloc=1&loc_id=');?>" + myselect.options[myselect.selectedIndex].value + "&photo_id=" + photoid;
			  }
			}
		</script>
		<div id="main-content">
			<div class="container-fluid">
				<div class="row-fluid">
					<div class="span12">
						<h3 class="page-title">
							Quản lí ảnh  <small></small>
						</h3>
					</div>
				</div>
				<?php echo $this->render('./includes/display_alert_message.phtml');?>
				<div class="row-fluid">			
					<div class="span12">
						<div class="widget">
							<div class="widget-title">
								<h4>
									<i class="icon-camera-retro"></i>Ảnh chưa xử lí của tôi  (<?php echo $this->total_my_photo;?>)
								</h4>
							</div>
							<div class="widget-body">
								<div class="row-fluid">
									<div class="span6">
										<form action="" method="post" enctype="multipart/form-data">
											<input type="file" name="picture"/>
											<input type="hidden" name="single" value="1"/>
											<button type="submit" class="btn btn-small btn-info" name="btnAdd">
											<i class="icon-upload-alt"> </i>
											Upload 1 ảnh 
											</button>
										</form>
									</div>
									<div class="span6">
										<form action="" method="post" enctype="multipart/form-data">
											<input type="file" name="picture[]" multiple="multiple"/>
											<input type="hidden" name="multi" value="1"/>
											<button type="submit" class="btn btn-small btn-info" name="btnAdd">
											<i class="icon-upload-alt"> </i>
											Upload nhiều  ảnh 
											</button>
										</form>
									</div>
								</div>
								
								<hr/>
								
								<?php if(count($this->arrMyIdlePhoto) != 0) {?>
								<div class="row-fluid">
									<p><small> Click vào ảnh để chỉnh sửa </small></p>
									<?php foreach ($this->arrMyIdlePhoto as $myphoto){?>
										<div class="span2" style="margin-left: 0px; margin-top: 20px;">
										<a href="#myModal<?php echo $myphoto['photo_id'];?>"
										role="button" data-toggle="modal">
										<img src="<?php echo $this->baseUrl(UPLOAD_PHOTO_DIRECTORY.$myphoto['photo_link']);?>" alt="" style="height: 120px; width: 110px;" />
										</a>
										<div id="myModal<?php echo $myphoto['photo_id'];?>" class="modal hide fade" tabindex="-1"
										role="dialog" aria-labelledby="myModalLabel<?php echo $myphoto['photo_id'];?>"
										aria-hidden="true">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"
												aria-hidden="true">×</button>
											<h3 id="myModalLabel<?php echo $myphoto['photo_id'];?>">Chỉnh sửa hình ảnh </h3>
										</div>
										<div class="modal-body">
										<div class="span5">
											<img src="<?php echo $this->baseUrl(UPLOAD_PHOTO_DIRECTORY.$myphoto['photo_link']);?>" alt="" class="span12" />
										</div>
										<div class="span7">
										<select class="span12" data-placeholder="Select option" tabindex="1" style="margin-left: 6px; margin-top: 10px;" id="<?php echo $myphoto['photo_id'];?>" onChange="jsFunction('<?php echo $myphoto['photo_id'];?>')">
													<option value="">--- Chọn ---</option>
													<option value="1">Nhóm </option>
													<option value="2">Địa điểm </option>
												</select>
												<select class="span11" data-placeholder="Select option" tabindex="1" style="margin-left: 6px; margin-top: 10px; display: none;" id="tour<?php echo $myphoto['photo_id'];?>" onChange="tourFunction('tour<?php echo $myphoto['photo_id'];?>', <?php echo $myphoto['photo_id'];?>)">
													<option value="">Chọn một nhóm </option>
													<?php if(count($this->arrMyTourInfo) != 0) {?>
													<?php foreach ($this->arrMyTourInfo as $myto) {?>
													<?php if(isset($myto[0]['tour_id']) && isset($myto[0]['name'])) {?>
													<option value="<?php echo $myto[0]['tour_id']?>"><?php echo ($myto[0]['name']);?></option>
													<?php }?>
													<?php }?>
													<?php }?>
												</select>
												<select class="span11" data-placeholder="Select option" tabindex="1" style="margin-left: 6px; margin-top: 10px; display: none;" id="loc<?php echo $myphoto['photo_id'];?>" onChange="locFunction('loc<?php echo $myphoto['photo_id'];?>', <?php echo $myphoto['photo_id'];?>)">
													<option value="">Chọn một địa điểm </option>
													<?php if(count($this->arrMyLoc) != 0) {?>
													<?php foreach ($this->arrMyLoc as $myloc) {?>
													<?php if(isset($myloc['location_id']) && isset($myloc['name'])) {?>
													<option value="<?php echo $myloc['location_id']?>"><?php echo ($myloc['name']);?></option>
													<?php }?>
													<?php }?>
													<?php }?>
												</select>
											</div>
										</div>
										<div class="modal-footer">
											<a href="<?php echo $this->baseUrl('/photo/?delete=1&photo_id='.$myphoto['photo_id']);?>" class=" btn btn-danger" title="Xoá " onclick="return confirm('Xoá ảnh?');"> <i class="icon-trash"></i> Xoá </a>
											<button data-dismiss="modal" class="btn">Đóng </button>
										</div>
									</div>
										</div>
										<?php }?>
								</div>
								
 								<?php echo $this->paginationControl($this->arrMyIdlePhoto, 'Sliding' , './includes/mpagination.phtml'); ?>
 								<?php }?>
							</div>
						</div>
					</div>
				</div>
				<div class="row-fluid">
					<div class="span12">
						<div class="widget">
							<div class="widget-title">
								<h4>
									<i class="icon-camera-retro"></i>Tổng số ảnh : <?php echo $this->total_photo;?>
								</h4>
							</div>
							<div class="widget-body">
								<table class="table table-striped table-bordered" id="sample_1">
									<thead>
										<tr>
											<th>Ảnh </th>
											<th class="hidden-phone">Người tạo  </th>
											<th class="hidden-phone">Nhóm </th>
											<th class="hidden-phone">Địa điểm </th>
											<th class="hidden-phone">Được tạo </th>
											<th class="hidden-phone"></th>
										</tr>
									</thead>
									<tbody>
									<?php 
									if(count($this->arrPhoto) != 0) {
									$iCountPhoto = 0;
									foreach ($this->arrPhoto as $photo) {?>
										<tr class="odd gradeX">
										
											<td>
												<div class="thumbnail" style="height: 50px; width: 50px;">
												<div class="item" style="height: 50px; width: 50px;">
													<a class="fancybox-button" data-rel="fancybox-button"
														title="" href="<?php echo  $this->baseUrl(UPLOAD_PHOTO_DIRECTORY.$photo['photo_link']); ?>"><div
															class="zoom">
															<img src="<?php echo  $this->baseUrl(UPLOAD_PHOTO_DIRECTORY.$photo['photo_link']); ?>" alt="" style="height: 50px; width: 50px;" />
															<div class="zoom-icon" style="height: 50px; width: 50px;"></div>
														</div></a>
													</div>
												</div>
												
											</td>
											<td class="hidden-phone">
												<?php if(isset($this->arrUser[$iCountPhoto][0]['username'])) {?>
												<?php echo  $this->arrUser[$iCountPhoto][0]['username'];?>
												<?php }?>
											</td>
											<td class="hidden-phone"><?php echo isset($this->arrTour[$iCountPhoto][0]['name']) ? ($this->arrTour[$iCountPhoto][0]['name']) : '---';?></td>
											<td class="center hidden-phone"><?php echo isset($this->arrLoc[$iCountPhoto][0]['name']) ? ($this->arrLoc[$iCountPhoto][0]['name']) : '---';?></td>
											<td class="center hidden-phone"><?php echo  $photo['created_time']; ?></td>
											<td class="hidden-phone span2">
												<a href="<?php echo $this->baseUrl('/photo/?delete=1&photo_id='.$photo['photo_id']);?>" class="btn btn-danger" title="Xoá " onclick="return confirm('Xoá ảnh?');"> <i class="icon-trash"></i> Xoá</a>
									
												</td>
										</tr>
										<?php 
										$iCountPhoto++;
										}
										}?>
									</tbody>
								</table>
								<?php if(count($this->arrPhoto) != 0) {?>
 								<?php echo $this->paginationControl($this->arrPhoto, 'Sliding' , './includes/pagination.phtml'); ?>
 								<?php }?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php echo $this->render('./includes/footer.phtml');?>